package cn.ly.security.service.impl;

import cn.ly.security.controller.InfoController;
import cn.ly.security.dao.InfoMapper;
import cn.ly.security.entity.Info;
import cn.ly.security.service.InfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Set;

@Service
public class InfoServiceImpl extends ServiceImpl<InfoMapper, Info> implements InfoService {

    @Autowired
    InfoMapper infoMapper;

    @Override
    public List<Map<String, Object>> lyGetInfoList(Page<Map<String, Object>> page) {
        // 新建分页
        Page<Map<String,Object>> page1 = new Page<>(1, 4);
        List<Map<String, Object>> maps = infoMapper.lyGetInfoList(page1);
        for (Map<String, Object> map : maps) {
            Set<String> strings = map.keySet();
            for (String string : strings) {
                System.out.println(string+":"+map.get(string));
            }
            System.out.println("下一个");
        }
        // 返回分页结果 1为id
        return null;
    }

    @Override
    public List<Info> selectAllDevice(Integer current, Integer size) {
        List<Info> infos = infoMapper.selectAllDevice(current, size);
        return infos;
    }

    @Override
    public List<Info> selectDeviceByName(String iName,Integer current,Integer size) {
        List<Info> infos = infoMapper.selectDeviceByName(iName,(current-1)*size,size);
        return infos;
    }

    @Override
    public List<Info> selectAllByArea() {
        List<Info> infos = infoMapper.selectAllByArea();
        return infos;
    }

    @Override
    public List<Info> selectAreaByName(String iArea) {
        List<Info> infos = infoMapper.selectAreaByName(iArea);
        return infos;
    }

    @Override
    public Info selectSingleDeviceByName(String iName) {
        Info info = infoMapper.selectSingleDeviceByName(iName);
        return info;
    }
//    @Override
//    public Integer selectByCate(String cate) {
//        Integer integer = infoMapper.selectByCate(cate);
//        return integer;
//    }
}
